class BookmarkController {
	def params = [:]
	def flash = [:]
	def scaffold = Bookmark

	def index = { redirect(action: list, params: params) }
	/*	
		case 1 )If there is only une action then execute it
		case 2 )if there is more than one then execute that named 'index'
		case 3 ) if 'defaultaction' is defined this is the one to be execute it
	*/
	def list = {
	//	log.info("Info:Listing all elements from bookmark model")
	//	log.error("Error : Listing all elements from bookmark model")
	//	log.warn("Warn: Listing all elements from bookmark model")
	//	log.debug("Debug: Listing all elements from bookmark model")
		if (!params.max) params.max = 10
				[bookmarkList: Bookmark.list(params)]
	}

	def update = {
				def bookmarkInstance = Bookmark.get( params.id )
				if (bookmarkInstance) {
					bookmarkInstance.properties = params
					if(!bookmarkInstance.hasErrors() && bookmarkInstance.save() ) {
						flash.message = "Bookmark ${params.id} actualizado correctamente"
						redirect(action:show,id:bookmarkInstance.id)
					}
					else {
						render(view:'edit',model:[bookmarkInstance:bookmarkInstance])
					}
				}
				else {	
						flash.message = "El bookmark con el id: ${params.id} no fue encontrado"
						redirect(action:edit,id:params.id)
				}
		}		
	
	 def delete = {
        def bookmarkInstance = Bookmark.get( params.id )
        if(bookmarkInstance) {
            bookmarkInstance.delete()
            flash.message = "Bookmark ${params.id} deleted"
            redirect(action:list)
        }
        else {
            flash.message = "Bookmark not found with id ${params.id}"
            redirect(action:list)
        }
    }
		
		def createZip = {
				byte[] zip = "este texto"
				log.info("Zipenado texto")
				response.contentType ="application/octet-stream"
				log.info("Definiendo la cabecera")
				response.outputStream << zip 
				log.info("Agregando el zip al flujo de respuesta")
		}

	def createXml = {
				render (text:"<hello>world</hello>", contentType:"text/xml")
		}


	def showBookmark = {
				[bookmarks: Bookmark.list(params)]
	}

}

	
